<html>
<head><meta charset="utf-8"><title>Integration test for unwind safety (#407) · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html">Integration test for unwind safety (#407)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198116230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116230">(May 19 2020 at 19:39)</a>:</h4>
<p>So just to confirm, that I get things right.</p>
<p>There are two abstractions: some database which represents some knowledge about code (so it is a <code>RustIrDatabase</code>), and there is something like solver, which taking into account the knowledge,  tries to prove given goal (the <code>Solver</code>, which is basically a Prolog interpreter). Now what we want, is to make test, checking that when something in <code>RusIrDatabase</code> panics, then panic is properly forwarded, and the <code>Solver::solve</code> panics too. </p>
<p>I understand your concerns with creating actual Db for the test, as we want just a simple panicking, implementation of <code>RustIrDatabase</code> (or returning something valid but without an actual meaning). Being honest I very don't like a <code>Mock</code> name for this - it is a <code>Stub</code>, or <code>Fake</code> object, but not mock (I find mock as something with highly customizable calls, which allows to check what was happening with it during the test). However I would not fight for naming and follow whatever convention is in there, if there is some.</p>
<p>My only concern here is how to create a <code>Solver</code> properly - I see this is some kind of salsa trait which allows to return this, but i don't see any implementation of that - I suppose <code>#[salsa::query_group(...)]</code> does a job, but I never used salsa before, so I will need to went into that to understand the API (I know the concept of salsa on some level).</p>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> am I on right track? I mention you as you pointed yourself as a contact ;)</p>



<a name="198116631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116631">(May 19 2020 at 19:42)</a>:</h4>
<p>Yeah, so basically if one of the methods in <code>RustIrDatabase</code> panics, we want the solver's state to be intact still. (So if the user catches the panic, they can reuse the solver)</p>



<a name="198116650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116650">(May 19 2020 at 19:42)</a>:</h4>
<p>As far as naming, it doesn't really matter</p>



<a name="198116672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116672">(May 19 2020 at 19:43)</a>:</h4>
<p>To create a solver, let me point you to that code</p>



<a name="198116738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116738">(May 19 2020 at 19:43)</a>:</h4>
<p><a href="https://github.com/rust-lang/chalk/blob/master/chalk-solve/src/solve.rs#L216">https://github.com/rust-lang/chalk/blob/master/chalk-solve/src/solve.rs#L216</a> is one entrypoint</p>



<a name="198116801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116801">(May 19 2020 at 19:44)</a>:</h4>
<p>then you just call <code>.solve()</code></p>



<a name="198116890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116890">(May 19 2020 at 19:44)</a>:</h4>
<p>I think there was some more discussion on zulip. Let me see if I can find it</p>



<a name="198116968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198116968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198116968">(May 19 2020 at 19:45)</a>:</h4>
<p><a href="#narrow/stream/144729-wg-traits/topic/New.20contributor/near/194591619">https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/New.20contributor/near/194591619</a></p>



<a name="198117102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198117102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198117102">(May 19 2020 at 19:46)</a>:</h4>
<p>Also I made a commit separately that made some progress: <a href="https://github.com/jackh726/chalk/commit/5f0c038ebaccfe3994a7aa98390cb841fdbbfee0">https://github.com/jackh726/chalk/commit/5f0c038ebaccfe3994a7aa98390cb841fdbbfee0</a></p>



<a name="198117194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198117194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198117194">(May 19 2020 at 19:47)</a>:</h4>
<p>The test fails</p>



<a name="198117221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198117221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198117221">(May 19 2020 at 19:47)</a>:</h4>
<p>So the majority of the work is mostly just figuring out <em>why</em></p>



<a name="198117427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198117427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198117427">(May 19 2020 at 19:49)</a>:</h4>
<p>If I remember correctly, the first problem <em>here</em> is that we push strands <em>after</em> adding the table: <a href="https://github.com/rust-lang/chalk/blob/master/chalk-engine/src/logic.rs#L225">https://github.com/rust-lang/chalk/blob/master/chalk-engine/src/logic.rs#L225</a></p>



<a name="198117482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198117482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198117482">(May 19 2020 at 19:49)</a>:</h4>
<p>And if there is a panic while pushing strands, then there is an empty table, which isn't correctly</p>



<a name="198118033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198118033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198118033">(May 19 2020 at 19:54)</a>:</h4>
<p>So the task is not actually to write the test (I can use your commit as test which should pass), but finding the bug in code (or in test), right?</p>



<a name="198118162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198118162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198118162">(May 19 2020 at 19:55)</a>:</h4>
<p>I obviously agree that naming it is not this important - I just mentioned it as side note</p>



<a name="198133512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198133512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198133512">(May 19 2020 at 22:10)</a>:</h4>
<p>Ok, I went a little deeper into that and I think I see what happens there. You pointed me almost directly into a problem. In <code>logic.rs</code> you are actually creating some new table, and trying to fullfill it with some initial data in <code>Forest::push_initial_strands</code>, but it fails, if something  panics internally (in particular: when there is a panic in database). What happens is, that the table is in invalid state (in terms: it is not filled properly), but next time <code>Forest::solve</code> is called (which is called directly from <code>Solver::solve</code>), the table is just taken from call it "cache" - without any  retry of pushing initial strands, so it is just an invalid table in this context.</p>
<ul>
<li>The "functional" way of solving the issue would be not to insert a table unless it is properly initialized. Making quick review I see, that calls are pretty simple:<ul>
<li><code>push_initial_strands</code> - this guy uses <code>table_goal</code>, but we don't need to insert table to have it - we are inserting it into the table</li>
<li><code>push_initial_strands_instantiated</code> - here magic happens, but first thing which is done is taking mutable borrow to the just inserted table; as I assume, that there are no nasty unsafes here, I am pretty much confident, that nothing uses the <code>tables</code> until all strands are inserted, so we don't need it to be in the tables yet</li>
</ul>
</li>
<li>The "catch an exception" way which I hate - the whole <code>push_initial_strands_instantiated</code> call can be wrapped into <code>catch_unwind</code> call, so when some panic happens here, the table is removed from tables.</li>
<li>The "mark when done" approach, is to add some marker to the tables, which indicates if table is properly configured. Initially the marker would be set on <code>false</code> (or some <code>enum</code> to improve readability), then just after <code>push_initial_strands</code> returns, the marker is set to <code>true</code>.  On <code>logic.rs:216</code> additional check would be added - if table is not valid, <code>push_initial_strands</code> is called on it again. The problem with this approach (despite the additional overhead which is probably unnoticeable) is, that I am not really sure that calling <code>push_initial_strands</code> on partially filled table is a good idea - I suppose, that the final state of the table can become a mess.</li>
</ul>
<p>For now I would like to proceed with my "functional" approach as I find it the cleanest one and I don't see why it doesn't work. However I am not very much aware about how exactly Chalk works, and I don't exactly know what is "the NFTD paper" referenced in doc-comment above so I cannot exactly verify what is going on in there (however I have a brief idea how Prolog interpreters work, so I can imagine the approach basics).</p>
<p>I just wanted to leave this here so if anyone sees any major missunderstanding on my side, may raise some alert here, as I am pretty much new here.</p>



<a name="198206575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198206575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198206575">(May 20 2020 at 14:30)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> I think I have working correction for that (if I located problem correctly), but I am wondering if there is a simple way to figure out which program clauses should be returned to solver, so the given goal is provable? My guess is that I just need to add clause "struct 1 implements trait 0" (if I understand clause properly), so I just want to return such from <code>custom_clauses</code> - I will go through doc to understand types structure, but if there is an easy way, it might help.</p>



<a name="198210481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198210481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198210481">(May 20 2020 at 14:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="208882">Bartłomiej Kuras</span> <a href="#narrow/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407)/near/198118033">said</a>:</p>
<blockquote>
<p>So the task is not actually to write the test (I can use your commit as test which should pass), but finding the bug in code (or in test), right?</p>
</blockquote>
<p>I wouldn't call this so bug a bug, as more a design direction: Chalk really hasn't been designed with panic safety in mind. So the "goal" here is to think about it and see what we can do to make it more panic safe.</p>



<a name="198210727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198210727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198210727">(May 20 2020 at 14:59)</a>:</h4>
<p>I think in the test I made, all the clauses need to solve the goal are there</p>



<a name="198211114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198211114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198211114">(May 20 2020 at 15:01)</a>:</h4>
<p>Another thing to think about is that we already store answers for each table. So it might be worth testing if we can solve <em>already completed</em> answers, as well as <em>new</em> answers</p>



<a name="198211219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198211219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198211219">(May 20 2020 at 15:02)</a>:</h4>
<p>It <em>might</em> be better to use <code>solve_multiple</code> for that</p>



<a name="198214429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198214429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198214429">(May 20 2020 at 15:23)</a>:</h4>
<p>A bug, not a bug - that is nomenclature, important thing we have common understanding - we need to modify code so panic doesn't leave solver on invalid state.</p>



<a name="198214735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198214735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198214735">(May 20 2020 at 15:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407)/near/198210727">said</a>:</p>
<blockquote>
<p>I think in the test I made, all the clauses need to solve the goal are there</p>
</blockquote>
<p>I don't think it is true for very specific reason - I just commented out the part with panicking solve, and left only the "correct" one, and in such case the test still fails (but panic didn't disturb solver, because there was no panic).</p>



<a name="198215351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198215351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198215351">(May 20 2020 at 15:28)</a>:</h4>
<p>Reason why I think I solved at least part of the problem is that I did some debugging, and for the second <code>solve</code> call, functions from DB wasn't called at all (and actually some internal table was left in invalid state, and reused from cache I think). Anyway before my correction, there was very different behavior (in terms on that happens internally) if panic occurred - now, flows are the same.</p>



<a name="198215443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198215443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198215443">(May 20 2020 at 15:29)</a>:</h4>
<p>Obviously I may be missing something - I would investigate what happens further so I can understand it better</p>



<a name="198220045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220045">(May 20 2020 at 16:03)</a>:</h4>
<p>Oh, it's completely possible my test isn't complete</p>



<a name="198220051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220051">(May 20 2020 at 16:03)</a>:</h4>
<p>Sorry :/</p>



<a name="198220061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220061">(May 20 2020 at 16:03)</a>:</h4>
<p>Don't worry</p>



<a name="198220069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220069">(May 20 2020 at 16:03)</a>:</h4>
<p>I found simple way</p>



<a name="198220093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220093">(May 20 2020 at 16:03)</a>:</h4>
<p>I just go to parent commit, check what original DB returns</p>



<a name="198220097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220097">(May 20 2020 at 16:03)</a>:</h4>
<p>So if you comment out the panic it doesn't work?</p>



<a name="198220102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220102">(May 20 2020 at 16:03)</a>:</h4>
<p>analyze it</p>



<a name="198220155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220155">(May 20 2020 at 16:04)</a>:</h4>
<p>and try to put it in</p>



<a name="198220165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220165">(May 20 2020 at 16:04)</a>:</h4>
<p>no, it doesn't</p>



<a name="198220206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220206">(May 20 2020 at 16:04)</a>:</h4>
<p>so now my approach is to move minimal set of things returned from original db to test, so the test work without the panic</p>



<a name="198220232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220232">(May 20 2020 at 16:04)</a>:</h4>
<p>then check if my correction works with* panic</p>



<a name="198220346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198220346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198220346">(May 20 2020 at 16:05)</a>:</h4>
<p>I am pretty confident it wont take too much time</p>



<a name="198229598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198229598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198229598">(May 20 2020 at 17:17)</a>:</h4>
<p>Oops yeah, <code>impls_for_trait</code> isn't implemented correctly</p>



<a name="198230119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198230119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198230119">(May 20 2020 at 17:22)</a>:</h4>
<p>this is the easy one - just <code>vec![ImplId(RawId { index: 1 }]</code> - I assume it is just some impl block id</p>



<a name="198230136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198230136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198230136">(May 20 2020 at 17:22)</a>:</h4>
<p>the problem is right after that</p>



<a name="198230188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198230188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198230188">(May 20 2020 at 17:22)</a>:</h4>
<p>Because it turns out, that <code>impl_datum</code> is called</p>



<a name="198230243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198230243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198230243">(May 20 2020 at 17:23)</a>:</h4>
<p>for now i have something like this:</p>
<div class="codehilite"><pre><span></span><code>    fn impl_datum(&amp;self, id: ImplId&lt;ChalkIr&gt;) -&gt; Arc&lt;ImplDatum&lt;ChalkIr&gt;&gt; {
        assert_eq!(dbg!(id.0.index), 1);

        let substitution = Ty::new(
            &amp;ChalkIr,
            ApplicationTy {
                name: TypeName::Struct(StructId(RawId { index: 0 })),
                substitution: Substitution::empty(&amp;ChalkIr),
            },
        );

        let binders = Binders::new(
            ParameterKinds::new(&amp;ChalkIr),
            ImplDatumBound {
                trait_ref: TraitRef {
                    trait_id: TraitId(RawId { index: 0 }),
                    substitution: Substitution::from1(&amp;ChalkIr, substitution),
                },
                where_clauses: vec![],
            },
        );

        Arc::new(dbg!(ImplDatum {
            polarity: Polarity::Positive,
            binders,
            impl_type: ImplType::Local,
            associated_ty_value_ids: vec![],
        }))
    }
</code></pre></div>



<a name="198230396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198230396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198230396">(May 20 2020 at 17:24)</a>:</h4>
<p>the "substitution" field of trait_ref (or in general "binders" field) is not printed in very much details so I try reverse engineer it, but it is more difficult that I suspected it to be</p>



<a name="198231128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198231128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198231128">(May 20 2020 at 17:30)</a>:</h4>
<p>yay! the problem was in struct id of substitution - I put 0, when on environment there is 1. This makes me happy, cause my tests passes when there is no crash, and I can easly go forward</p>



<a name="198238029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198238029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198238029">(May 20 2020 at 18:24)</a>:</h4>
<p>// I have a PR for this: <a href="https://github.com/rust-lang/chalk/pull/462">https://github.com/rust-lang/chalk/pull/462</a> (edited because of bad link pasted)</p>
<p>Edit - forget that, I just realized some actions didn't pass</p>



<a name="198246362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198246362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198246362">(May 20 2020 at 19:32)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> Ok, now PR is passing checks: <a href="https://github.com/rust-lang/chalk/pull/462">https://github.com/rust-lang/chalk/pull/462</a></p>
<p>I screwed not merging master to my branch, as your commit was "couple" commits behind (I should expect that considering when previous discussion took place). Now it is fine (in terms of being up to date at least. I mention you, as you were reviewer of previous iterations - I don't know yet if there are any guidlines how to provide PRs.</p>



<a name="198257014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198257014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198257014">(May 20 2020 at 21:03)</a>:</h4>
<p>I'll take a look :)</p>



<a name="198257017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198257017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198257017">(May 20 2020 at 21:03)</a>:</h4>
<p>thanks</p>



<a name="198257024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198257024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198257024">(May 20 2020 at 21:03)</a>:</h4>
<p>You can always rebase</p>



<a name="198290684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Integration%20test%20for%20unwind%20safety%20%28%23407%29/near/198290684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Bartłomiej Kuras <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Integration.20test.20for.20unwind.20safety.20(.23407).html#198290684">(May 21 2020 at 06:33)</a>:</h4>
<p>Sure I can - I personaly prefer merging master than rebase, but I would fit to any idioms you are using here.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>